public class Test {
    public void reverse(int[] nums,int start,int end){
        while(start<end){
            int tmp=nums[start];
            nums[start]=nums[end];
            nums[end]=tmp;
            start+=1;
            end-=1;
        }
    }
    public void rotate(int[] nums, int k) {
        int n=nums.length;
        //旋转全部数组
        reverse(nums,0,n-1);
        reverse(nums,0,(k%n)-1);
        reverse(nums,k%n,n-1);
    }
    /*public static void rotate(int[] nums, int k) {
        int n=nums.length;
        //创建一个新的数组
        int[] Newnums=new int[n];
        for(int i=0;i<n;i++){
            Newnums[(i+k)%n]=nums[i];
        }
        System.arraycopy(Newnums,0,nums,0,n);
    }*/
    public static void main(String[] args) {

    }
}
